var path = require('path');
var webpack = require('webpack');

var url='http://localhost';   // 全部的转发请求
var oneselfUrl='localhost';

module.exports = {
  entry: {
      index:'./src/main.js',
      superlative:'./innovation/superlative.js'
  },
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: process.env.NODE_ENV === 'production' ? './../../../vue/vue_two/dist/' : '/dist/',   // 临时图片路径区域
    filename: '[name].build.js'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
          }
          // other vue-loader options go here
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.css$/,
        loader: 'style!css'
      },
      {
        test: /\.less$/,
        loader: 'style!css!less'
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  resolve: {
    alias: {
        'vue$': 'vue/dist/vue.common.js',
        '@': 'src',
        'n@': 'innovation/components'
    }
  },
  devServer: {
    host: oneselfUrl,
    port:8085,
    historyApiFallback: true,
    noInfo: true,
      proxy: {
     '/employee_valid': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/getPortalData': {
          target: url,
          changeOrigin: true,
          secure: false
      } ,'/airRoute/': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/indexd': {
          target: url,
          changeOrigin: true,
          secure: false
      } ,'/roleEmployeeDelete': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/rolenew_update': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/roleEmployeeUpdate': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/roleEmployeeAdd': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/getEmployees': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/employee_update': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/rolenew_delete': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/rolenew_add': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/getAirportViewData': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/restful/': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/rolenew_getList': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      , '/checkLogin': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/bindMail': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/employee_load': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/unbindMail': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/switchPhone': {
          target: url,
          changeOrigin: true,
          secure: false
      }
      ,'/getValidCode': {
          target: url,
          changeOrigin: true,
          secure: false
      } ,'/employee_upwd': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/outLogin': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/getCurrentSeasonFocusFlts': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/getAirportOnLineData': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/updateFocusFltList': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/configuration_list': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/getEtermAirportOnLineData': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/eterm_test': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/addeTerm': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/eterm_delete': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/userCommit/': {
          target: url,
          changeOrigin: true,
          secure: false
      },'/findFilterParamAirPort': {
          target: url,
          changeOrigin: true,
          secure: false
      }
    }
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
};
new webpack.optimize.UglifyJsPlugin({
    compress: {
        warnings: false
    }
})
if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}
